<template>
  <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input v-model="taskname"
    @keydown.enter="hAdd"
     class="new-todo"
      placeholder="请输入任务名称" 
      autofocus />
  </header>
</template>

<script>
export default {
  name: 'TodoHeader',

  data() {
    return {
      taskname:''
    };
  },

 methods: {
    hAdd(){
      //非空判断
if(this.taskname==='') return

//子传父
this.$emit('addTask',this.taskname);
this.taskname=''
    }
  },
};
</script>

<style lang="scss" scoped>

</style>